package com.proxy.demo;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

public class Meipo implements InvocationHandler {

    private Person target;

    public Object getInstance(Person target){
        this.target = target;
        Class clazz = target.getClass();
        return Proxy.newProxyInstance(clazz.getClassLoader(),clazz.getInterfaces(),this);
    }


    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
//        System.out.println("我是媒婆：你的性别是:"+this.target.getSex());
        System.out.println("我是媒婆：你得找个异性");
        System.out.println("开始查找...");
        this.target.findLove();
        System.out.println("OK ");
        return null;
    }
}
